﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;

public class InputController : MonoBehaviour 
{

    public GameObject m_3DMenuButtons;
    private bool isShow3DMenu;
    public Transform m_3DMenuPos;
    void Start()
    {
        m_3DMenuButtons.SetActive(false);
        GetComponent<VRTK_ControllerEvents>().ButtonTwoPressed += new ControllerInteractionEventHandler(DoStartMenuPressed);
        GetComponent<VRTK_ControllerEvents>().ButtonOnePressed += new ControllerInteractionEventHandler(DoStartMenuPressed);
    }

    private void DoStartMenuPressed(object sender, ControllerInteractionEventArgs e)
    {
        isShow3DMenu = !isShow3DMenu;
        Set3DMenu(isShow3DMenu);
    }

    void Set3DMenu(bool isShow)
    {
        m_3DMenuButtons.SetActive(isShow);
        m_3DMenuButtons.transform.position = m_3DMenuPos.position;
        m_3DMenuButtons.transform.localEulerAngles = m_3DMenuPos.eulerAngles;
        if (isShow==true)
        {
            GetComponent<VRTK_Pointer>().pointerRenderer = GetComponent<VRTK_StraightPointerRenderer>();
        }
        else
        {
            GetComponent<VRTK_Pointer>().pointerRenderer = GetComponent<VRTK_BezierPointerRenderer>();
        }
    }
}
